import 'dart:math' as math;

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:gluz/app/data/country_entity.dart';
import 'package:gluz/app/data/shop/shop_detail_entity.dart';
import 'package:gluz/app/data/shop/shop_evaluate_entity.dart';
import 'package:gluz/app/utils/colors.dart';

import '../../../../common/tabbar_indicator.dart';
import '../controllers/product_detail_controller.dart';

class ProductDetailView extends GetView<ProductDetailController> {
  const ProductDetailView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: _buildAppBar(),
      body: GetBuilder<ProductDetailController>(
        builder: (controller) {
          if (controller.shopDetailEntity == null) {
            return Center(child: Text('暂无数据'.tr, style: TextStyle(color: Colors.grey),));
          }
          return Stack(
            children: [
              _buildScrollableContent(),
              _buildExplanationPopup(),
              _buildBottomToolbar(),
            ],
          );
        },
      ),
    );
  }

  PreferredSizeWidget _buildAppBar() {
    return AppBar(
      backgroundColor: Colors.black,
      elevation: 0,
      leading: IconButton(
        icon: const Icon(Icons.arrow_back_ios, color: Colors.white),
        onPressed: controller.onBackTap,
      ),
      title: Text(
        '详情'.tr,
        style: const TextStyle(
          color: Colors.white,
          fontSize: 18,
          fontWeight: FontWeight.bold,
        ),
      ),
      centerTitle: true,
      actions: [
        IconButton(
          icon: Image.asset(
            'assets/images/shop/shop_share_icon.png',
            width: 22,
          ),
          onPressed: controller.onShareTap,
        ),
      ],
    );
  }

  Widget _buildScrollableContent() {
    return GetBuilder<ProductDetailController>(
      builder: (controller) {
        return CustomScrollView(
          slivers: [
            // 轮播图
            SliverToBoxAdapter(child: _buildProductBanner()),
            // 商品基础信息
            SliverToBoxAdapter(child: _buildProductBasicInfo()),
            // 店铺信息
            SliverToBoxAdapter(child: _buildStoreInfo()),
            // 3D展示
            SliverToBoxAdapter(child: _buildProduct3DDisplay()),
            // TabBar
            SliverToBoxAdapter(child: _buildTabBar()),
            // Tab内容
            SliverToBoxAdapter(child: _buildTabContent()),

            SliverToBoxAdapter(child: const SizedBox(height: 80)),
          ],
        );
      },
    );
  }

  Widget _buildProductBanner() {
    return Container(
      height: 250.h,
      child: Obx(() {
        return Stack(
          children: [
            // 轮播图
            PageView.builder(
              controller: controller.bannerController,
              onPageChanged: controller.onBannerPageChanged,
              itemCount: controller.mediaList.length,
              itemBuilder: (context, index) {
                ShopDetailImages images = controller.mediaList[index];
                return InkWell(
                  onTap: () => controller.onMediaTap(index),
                  child: Stack(
                    alignment: AlignmentDirectional.center,
                    children: [
                      Positioned.fill(
                        child: CachedNetworkImage(
                          imageUrl: images.getPicUrl(),
                          fit: BoxFit.cover,
                          width: double.infinity,
                          placeholder: (context, url) => Container(
                            color: Colors.grey[200],
                            child: const Center(
                              child: CircularProgressIndicator(),
                            ),
                          ),
                          errorWidget: (context, url, error) => Container(
                            color: Colors.grey[200],
                            child: const Icon(Icons.error),
                          ),
                        ),
                      ),
                      // 如果是视频则展示播放按钮
                      if (images.type == '2')
                        Container(
                          width: 60.w,
                          height: 60.w,
                          decoration: BoxDecoration(
                            color: Colors.black.withValues(alpha: 0.3),
                            shape: BoxShape.circle,
                          ),
                          child: const Icon(
                            Icons.play_arrow,
                            size: 30,
                            color: Colors.white,
                          ),
                        ),
                    ],
                  ),
                );
              },
            ),
            // 页面指示器
            Positioned(
              bottom: 20.h,
              left: 0,
              right: 0,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: List.generate(
                  controller.mediaList.length,
                  (index) => Obx(
                    () => Container(
                      width: 8.w,
                      height: 8.w,
                      margin: EdgeInsets.symmetric(horizontal: 4.w),
                      decoration: BoxDecoration(
                        color: controller.currentBannerIndex.value == index
                            ? Colors.white
                            : Colors.white.withOpacity(0.5),
                        shape: BoxShape.circle,
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ],
        );
      }),
    );
  }

  Widget _buildProductBasicInfo() {
    return Container(
      padding: EdgeInsets.all(16.w),
      child: Stack(
        children: [
          Positioned(
            child: Image.asset(
              'assets/images/shop/shop_info_bg.png',
              fit: BoxFit.fill,
            ),
          ),
          Positioned(
            top: 15,
            left: 5,
            right: 5,
            bottom: 10,
            child: Stack(
              children: [
                Image.asset(
                  'assets/images/shop/shop_info_white_bg.png',
                  fit: BoxFit.fill,
                ),
                Positioned(
                  top: 10,
                  right: 15,
                  child: Row(
                    children: [
                      Row(
                        children: [
                          SizedBox(
                            height: 16, // 高度取决于头像大小
                            width: 50,
                            child: Stack(
                              children: List.generate(3, (index) {
                                return Positioned(
                                  left: index * 8,
                                  child: CircleAvatar(
                                    radius: 8,
                                    backgroundImage: CachedNetworkImageProvider(
                                      'https://gluz-oss.oss-cn-beijing.aliyuncs.com/avatars/gluz_avatar.png',
                                    ),
                                  ),
                                );
                              }),
                            ),
                          ),
                          Text(
                            '${controller.shopDetailEntity?.pageView ?? 0}${'人'.tr}',
                            style: TextStyle(
                              fontSize: 10.sp,
                              color: Colors.orange,
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
                Padding(
                  padding: EdgeInsets.symmetric(horizontal: 10),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(height: 30.h),
                      // 运费信息
                      Row(
                        children: [
                          Container(
                            padding: EdgeInsets.symmetric(
                              horizontal: 5.w,
                              vertical: 2.h,
                            ),
                            decoration: BoxDecoration(
                              color: Colors.red.withOpacity(0.8),
                              borderRadius: BorderRadius.circular(4.r),
                            ),
                            child: Text(
                              '不含运费',
                              style: TextStyle(
                                fontSize: 8.sp,
                                color: Colors.white,
                              ),
                            ),
                          ),
                          const Spacer(),
                          _buildBulkPricing(),
                        ],
                      ),
                      // 商品名称
                      Text(
                        controller.shopDetailEntity?.skuName ?? '商品名称',
                        style: TextStyle(
                          fontSize: 16.sp,
                          fontWeight: FontWeight.bold,
                        ),
                        overflow: TextOverflow.ellipsis,
                        maxLines: 2,
                      ),
                      SizedBox(height: 10.h),
                      // 商品统计信息
                      _buildProductStats(),
                    ],
                  ),
                ),
              ],
            ),
          ),
          Positioned(
            top: 10,
            left: 10,
            child: Text(
              '¥${controller.shopDetailEntity?.salesPrice ?? 0}',
              style: TextStyle(fontSize: 18.sp, color: Colors.white),
              maxLines: 2,
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildBulkPricing() {
    return Row(
      children: [
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              '¥50000',
              style: TextStyle(fontSize: 14.sp, color: Colors.black),
            ),
            Text('2辆起批', style: TextStyle(fontSize: 12.sp)),
          ],
        ),
        SizedBox(width: 4.h),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              '¥49000',
              style: TextStyle(fontSize: 14.sp, color: Colors.black),
            ),
            Text('5-10辆起批', style: TextStyle(fontSize: 12.sp)),
          ],
        ),
        SizedBox(width: 4.h),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              '¥48000',
              style: TextStyle(fontSize: 14.sp, color: Colors.black),
            ),
            Text('≥11辆起批', style: TextStyle(fontSize: 12.sp)),
          ],
        ),
      ],
    );
  }

  Widget _buildProductStats() {
    return Row(
      children: [
        _buildStatItem(
          'assets/images/shop/shop_info_qipi.png',
          '起批数量',
          '100',
          '件',
        ),
        _buildStatItem(
          'assets/images/shop/shop_info_qimai.png',
          '起卖数量',
          '100',
          '件',
        ),
        _buildStatItem(
          'assets/images/shop/shop_info_haoping.png',
          '好评率',
          '100',
          '%',
        ),
        _buildStatItem(
          'assets/images/shop/shop_info_shoucang.png',
          '收藏店铺',
          '100',
          '人',
        ),
      ],
    );
  }

  Widget _buildStatItem(
    String assetsName,
    String label,
    String value,
    String unit,
  ) {
    return Expanded(
      child: Row(
        children: [
          Image.asset(assetsName, width: 24),
          SizedBox(width: 2.h),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(label, style: TextStyle(fontSize: 10.sp)),
              Row(
                children: [
                  Text(
                    value,
                    style: TextStyle(
                      fontSize: 10.sp,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  Text(unit, style: TextStyle(fontSize: 6.sp)),
                ],
              ),
            ],
          ),
        ],
      ),
    );
  }

  Widget _buildStoreInfo() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 16.w),
      padding: EdgeInsets.all(16.w),
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter,
          colors: [Color(0xFFC7E2FF), Colors.white],
        ),
        boxShadow: [
          BoxShadow(
            color: Color(0xFFC7E2FF),
            blurRadius: 12,
            offset: const Offset(0, 4),
          ),
        ],
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Row(
        children: [
          Stack(
            children: [
              Transform.translate(
                offset: Offset(0, -5),
                child: Transform.rotate(
                  angle: -math.pi / 12,
                  child: ClipRRect(
                    borderRadius: BorderRadius.circular(10),
                    child: CachedNetworkImage(
                      imageUrl:
                          'https://gluz-oss.oss-cn-beijing.aliyuncs.com/OIP-C3.jpg',
                      width: 50,
                      height: 50,
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
              ),
              Positioned(
                bottom: 0,
                right: 0,
                left: 0,
                height: 15,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(6),
                  child: Image.asset(
                    CountryEntity.getCountryImage2(
                      controller.shopDetailEntity?.userCountry ?? '',
                    ),
                    fit: BoxFit.cover,
                  ),
                ),
              ),
            ],
          ),
          SizedBox(width: 12.w),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  controller.shopDetailEntity?.userName ?? '店铺名称',
                  style: TextStyle(
                    fontSize: 16.sp,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                SizedBox(height: 4.h),
                Row(
                  children: List.generate(5, (index) {
                    return Icon(
                      index < 4 ? Icons.star : Icons.star_half,
                      size: 16.w,
                      color: Colors.yellow,
                    );
                  }),
                ),
              ],
            ),
          ),
          // 店铺vip等级
          Image.asset(
            'assets/images/mine/mine_vip_flag_${controller.shopDetailEntity?.memberLevel}.png',
            width: 50,
          ),
        ],
      ),
    );
  }

  Widget _buildProduct3DDisplay() {
    return Container(
      margin: EdgeInsets.all(16.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '商品3D展示',
            style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.bold),
          ),
          SizedBox(height: 12.h),
          SizedBox(
            height: 100.h,
            child: ListView.builder(
              scrollDirection: Axis.horizontal,
              itemCount: controller.product3DImages.length,
              itemBuilder: (context, index) {
                ShopDetailImages images = controller.product3DImages[index];
                return GestureDetector(
                  onTap: () => controller.on3DImageTap(index),
                  child: Container(
                    width: 100.w,
                    margin: EdgeInsets.only(right: 12.w),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(8.r),
                      image: DecorationImage(
                        image: CachedNetworkImageProvider(images.getPicUrl()),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                );
              },
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildTabBar() {
    return TabBar(
      controller: controller.tabController,
      tabs: [
        Tab(text: '产品详情'),
        Tab(text: '用户评价'),
      ],
      labelColor: AppColors.color_278AFF,
      labelStyle: TextStyle(fontWeight: FontWeight.bold),
      unselectedLabelColor: Colors.black,
      unselectedLabelStyle: TextStyle(fontWeight: FontWeight.bold),
      indicatorColor: AppColors.color_278AFF,
      dividerColor: Colors.transparent, // 移除底部灰色线条

      indicator: TabBarCustomIndicator(),
    );
  }

  Widget _buildTabContent() {
    return GetBuilder<ProductDetailController>(
      builder: (controller) {
        if (controller.tabController.index == 0) {
          return _buildProductDetails();
        } else {
          return _buildUserReviews();
        }
      },
    );
  }

  Widget _buildProductDetails() {
    return Column(
      children: [
        Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(16),
            boxShadow: [
              BoxShadow(
                color: Colors.black.withAlpha(20),
                blurRadius: 5,
                offset: const Offset(0, 0),
              ),
            ],
          ),
          margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 5.w),
          padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.w),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              ...controller.productSpecs.map((spec) => _buildSpecItem(spec)),
            ],
          ),
        ),

        Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(16),
            boxShadow: [
              BoxShadow(
                color: Colors.black.withAlpha(20),
                blurRadius: 5,
                offset: const Offset(0, 0),
              ),
            ],
          ),
          margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 5.w),
          padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.w),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                '商品介绍',
                style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold),
              ),
              ...(controller.shopDetailDetail?.getIntroduceImages() ?? [])
                  .asMap()
                  .entries
                  .map(
                    (entry) => GestureDetector(
                      onTap: () => controller.onIntroImageTap(entry.key),
                      child: CachedNetworkImage(
                        imageUrl: entry.value,
                        fit: BoxFit.cover,
                      ),
                    ),
                  )
                  .toList(),
            ],
          ),
        ),
      ],
    );
  }

  Widget _buildSpecItem(Map<String, String> spec) {
    final key = spec.keys.first;
    final value = spec.values.first;
    return Container(
      padding: EdgeInsets.symmetric(vertical: 8.h),
      child: Row(
        children: [
          Text(
            key,
            style: TextStyle(fontSize: 14.sp, color: Colors.grey),
          ),
          Expanded(
            child: Text(
              value,
              style: TextStyle(fontSize: 14.sp),
              textAlign: TextAlign.right,
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildUserReviews() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 16, vertical: 5),
      padding: EdgeInsets.all(12.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16.r),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.1),
            blurRadius: 8,
            offset: const Offset(0, 2),
          ),
        ],
      ),
      child: Column(
        children: [
          // 评价类型选择
          Container(
            padding: EdgeInsets.symmetric(horizontal: 16.w),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                _buildReviewTypeTab('好评', '01'),
                _buildReviewTypeTab('不错', '02'),
                _buildReviewTypeTab('差评', '03'),
              ],
            ),
          ),
          SizedBox(height: 12.h),
          // 评价列表
          ...controller.evaluateList
              .map((evaluate) => _buildReviewItem(evaluate))
              .toList(),
        ],
      ),
    );
  }

  Widget _buildReviewTypeTab(String type, String emoji) {
    return Obx(
      () {
        bool isSelected = controller.selectedReviewType.value == type;
        return InkWell(
          onTap: () => controller.switchReviewType(type),
          child: Stack(
            children: [
            Image.asset('assets/images/shop/evaluate_$emoji${isSelected?'h':''}.png', width: 80,),
            Positioned(
              top: 10,
              right: 20,
              child: Text(type, style: TextStyle(fontSize: 12.sp, color: isSelected ? Colors.white : Colors.grey)),
            ),
          ],),
        );
      },
    );
  }

  Widget _buildReviewItem(ShopEvaluateEntity evaluate) {
    return Container(
      margin: EdgeInsets.only(bottom: 16.h),
      padding: EdgeInsets.all(12.w),
      decoration: BoxDecoration(
        color: Colors.grey[50],
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              CircleAvatar(
                radius: 16.w,
                backgroundImage: CachedNetworkImageProvider(evaluate.userImg),
              ),
              SizedBox(width: 8.w),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      evaluate.userName,
                      style: TextStyle(
                        fontSize: 14.sp,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    Text(
                      evaluate.createdTime,
                      style: TextStyle(fontSize: 12.sp, color: Colors.grey),
                    ),
                  ],
                ),
              ),
              Row(
                children: List.generate(evaluate.rating, (index) {
                  return Icon(
                    Icons.star,
                    size: 16.w,
                    color: Colors.yellow,
                  );
                }),
              ),
            ],
          ),
          SizedBox(height: 8.h),
          Text(evaluate.reviewContent, style: TextStyle(fontSize: 14.sp)),
          ...[
            SizedBox(height: 8.h),
            Container(
              padding: EdgeInsets.all(8.w),
              decoration: BoxDecoration(
                color: Colors.blue.withOpacity(0.1),
                borderRadius: BorderRadius.circular(4.r),
              ),
              child: Text(
                '商家回复:感谢您的支持, 您的支持让我们更有动力',
                style: TextStyle(fontSize: 12.sp, color: Colors.blue),
              ),
            ),
          ],
        ],
      ),
    );
  }

  Widget _buildExplanationPopup() {
    return Obx(() {
      if (!controller.isExplanationVisible.value) {
        return const SizedBox.shrink();
      }

      return Positioned(
        top: 150.h,
        right: 16.w,
        child: GestureDetector(
          onTap: controller.closeExplanationPopup,
          child: Container(
            width: 80.w,
            height: 100.h,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(8.r),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withOpacity(0.1),
                  blurRadius: 8,
                  offset: const Offset(0, 2),
                ),
              ],
            ),
            child: Column(
              children: [
                Stack(
                  children: [
                    Container(
                      width: 80.w,
                      height: 80.h,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(8.r),
                          topRight: Radius.circular(8.r),
                        ),
                        image: DecorationImage(
                          image: CachedNetworkImageProvider(
                            controller.mediaList.first.getPicUrl(),
                          ),
                          fit: BoxFit.cover,
                        ),
                      ),
                    ),
                    Positioned(
                      top: 4.h,
                      right: 4.w,
                      child: GestureDetector(
                        onTap: controller.closeExplanationPopup,
                        child: Container(
                          width: 16.w,
                          height: 16.w,
                          decoration: const BoxDecoration(
                            color: Colors.black54,
                            shape: BoxShape.circle,
                          ),
                          child: const Icon(
                            Icons.close,
                            size: 12,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
                Expanded(
                  child: Center(
                    child: Text(
                      '商品讲解',
                      style: TextStyle(
                        fontSize: 10.sp,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      );
    });
  }

  Widget _buildBottomToolbar() {
    return Positioned(
      bottom: 0,
      left: 0,
      right: 0,
      child: Container(
        height: 80.h,
        padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
        decoration: BoxDecoration(
          color: Colors.white,
          boxShadow: [
            BoxShadow(
              color: Colors.black.withOpacity(0.1),
              blurRadius: 8,
              offset: const Offset(0, -2),
            ),
          ],
        ),
        child: Row(
          children: [
            // 收藏按钮
            Obx(
              () => IconButton(
                padding: const EdgeInsets.all(0),
                iconSize: 20,
                onPressed: controller.toggleFavorite,
                icon: Icon(
                  controller.isFavorited.value
                      ? Icons.favorite
                      : Icons.favorite_border,
                  color: controller.isFavorited.value
                      ? Colors.red
                      : Colors.black,
                ),
              ),
            ),
            // 店铺按钮
            IconButton(
              iconSize: 20,
              padding: const EdgeInsets.all(0),
              onPressed: controller.enterStore,
              icon: const Icon(Icons.store, color: Colors.black),
            ),
            // 聊天按钮
            IconButton(
              iconSize: 20,
              padding: const EdgeInsets.all(0),
              onPressed: controller.startChat,
              icon: const Icon(Icons.chat_outlined, color: Colors.black),
            ),
            // 购物车按钮
            Stack(
              children: [
                IconButton(
                  iconSize: 20,
                  padding: const EdgeInsets.all(0),
                  onPressed: controller.enterCart,
                  icon: const Icon(Icons.shopping_cart_outlined, color: Colors.black),
                ),
                Obx(
                  () => controller.cartList.isNotEmpty
                      ? Positioned(
                          right: 8.w,
                          top: 8.h,
                          child: Container(
                            width: 16.w,
                            height: 16.w,
                            decoration: const BoxDecoration(
                              color: Colors.red,
                              shape: BoxShape.circle,
                            ),
                            child: Center(
                              child: Text(
                                '${controller.cartList.length}',
                                style: TextStyle(
                                  fontSize: 10.sp,
                                  color: Colors.white,
                                ),
                              ),
                            ),
                          ),
                        )
                      : const SizedBox.shrink(),
                ),
              ],
            ),
            const Spacer(),
            // 加入购物车按钮
            SizedBox(
              height: 30,
              child: ElevatedButton(
                onPressed: controller.addToCart,
                style: ElevatedButton.styleFrom(
                  backgroundColor: AppColors.color_278AFF,
                  foregroundColor: Colors.white,
                  padding: EdgeInsets.symmetric(horizontal: 12.w),
                  textStyle: TextStyle(fontSize: 10),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.only(topLeft: Radius.circular(15), bottomLeft: Radius.circular(15)),
                  ),
                ),
                child: Text('加入购物车'),
              ),
            ),
            // 立即购买按钮
            SizedBox(
              height: 30,
              child: ElevatedButton(
                onPressed: controller.buyNow,
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.orange,
                  foregroundColor: Colors.white,
                  padding: EdgeInsets.symmetric(horizontal: 12.w),
                  textStyle: TextStyle(fontSize: 10),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.only(topRight: Radius.circular(15), bottomRight: Radius.circular(15)),
                  ),
                ),
                child: Text('立即购买'),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
